package mipo.top.base.service.impl;

import mipo.top.admin.domain.Department;
import mipo.top.base.mapper.BaseMapper;
import mipo.top.base.query.BaseQuery;
import mipo.top.base.service.BaseService;
import mipo.top.base.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;


import java.util.List;

public class BaseServiceimpl<T> implements BaseService<T> {

    @Autowired
    private BaseMapper<T> baseMapper;

    public List<T> findall() {
        return baseMapper.findall();
    }

    public T findone(Long id) {
        return baseMapper.findone(id);
    }

    public void save(T t) {
        baseMapper.save(t);
    }

    public void update(T t) {
        baseMapper.update(t);
    }

    public void remove(Long id) {
        baseMapper.remove(id);
    }

    public PageUtil<T> queryData(BaseQuery query) {
        Integer count = baseMapper.count(query);
        List<T> t = baseMapper.pageQuery(query);
        return new PageUtil<T>(count,t);
    }

    public void patchremove(List<Long> ids) {
        baseMapper.patchremove(ids);
    }

}
